<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!--<script>
    function add(a,b){
        var c=a+b;
        return c;
    }

    var sum=add(3,4,4)
    console.log(sum);
    </script>-->
    <h2>大小写转换</h2>
    <input id="old" type="text">
    <input type="button" value="转大写" onclick="deal('upper')">
     <input type="button" value="转小写" onclick="deal('lower')">
     <input id="new" type="text">
     <script>
     function deal(opt){
         var str=document.getElementById('old').value;
         switch(opt){
             case 'upper':
             str=str.toUpperCase();
             break;
             case 'lower':
             str=str.toLowerCase();
             break;
         }
         document.getElementById('new').value=str;
     }
     </script>
    <!--方法二-->
     <!--<h2>大小写转换</h2>
    <input id="old" type="text">
    <input type="button" value="转大写"  id="button1">
     <input type="button" value="转小写" id="button2">
     <input id="new" type="text">
       <script>
       let str=document.getElementById('old').value;
       function deal(e){
        if(e.target==button1){
               str=str.toUpperCase();
           }else{
               str=str.toLowerCase();
           }
            document.getElementById('new').value=str;
       }
       
       let button1=document.getElementById('button1');
       button1.onclick=deal;
       let button2=document.getElementById('button2');
       button1.onclick=deal;
      
       </script>-->

    
</body>
</html>